<script>
export default {
  name: "list",
  data() {
    return {
      page1: [],
      serachName: '',
      serachClassification: '',
      serprocessor:'',
      pager: {
        pageNo: 1,
        pageSize: 3,
        total: 0,
        pages: 0
      }
    }
  },
  created() {
    this.getlist();
  },
  methods: {
    //确定删除
    deleteById(id) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        axios.delete('http://localhost:8080/api/recode/delete/' + id).then(res => {
          if (res.data.code == 200) {
            this.$message.success('删除成功');
            this.getlist();
          }
          if (res.data.code == 500) {
            this.$message.error('删除失败');
          }
        }
        )
          .catch(error => {
            console.log(error);
            this.$message.error('请求失败');
          })
      }
      )
    },
    getlist() {
      axios.get('http://localhost:8080/api/recode/getlist?studentName=' + this.serachName +
          '&pageNo=' + this.pager.pageNo + '&registrant=' + this.serachClassification+'&processor'+this.serprocessor).then(res => {
        this.page1 = res.data.data.records;
        this.pager.total = res.data.data.total;
        this.pager.pageSize = res.data.data.size;
        this.pager.pages = Math.ceil(this.pager.total / this.pager.pageSize);
      })
          .catch(error => {
            console.log(error);
            this.$message.error('请求失败');
          })
    }
  }
}


</script>

<template>
  <el-row>
    <el-col :span="24">
      <el-form :inline="true" >
        <el-form-item label="学生姓名">
          <el-input v-model="serachName" placeholder="请输入学生姓名"></el-input>
        </el-form-item>
        <el-form-item label="登记人">
          <el-input v-model="serachClassification" placeholder="请输入登记人"></el-input>
        </el-form-item>
        <el-form-item label="处理人">
          <el-input v-model="serprocessor" placeholder="请输入处理人"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button size="small" type="primary" @click="getlist">查询</el-button>
        </el-form-item>
      </el-form>
      <el-button size="small" type="primary" @click="$router.push('/add')">新增资产</el-button>
      <el-table :data="page1" border stripe>
        <el-table-column prop="studentName" label="学生姓名" ></el-table-column>
        <el-table-column prop="clazzname" label="所在班级" ></el-table-column>
        <el-table-column prop="reason" label="违规违纪原因" ></el-table-column>
        <el-table-column prop="createTime" label="登记时间" ></el-table-column>
        <el-table-column prop="registrant" label="登记人" ></el-table-column>
        //判断状态
        <el-table-column prop="status" label="处理状态" >
          <template slot-scope="scope">
            <el-tag v-if="scope.row.status==1" type="success">已处理</el-tag>
            <el-tag v-if="scope.row.status==2" type="danger">未处理</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="handleTime" label="处理时间" ></el-table-column>
        <el-table-column prop="processor" label="处理人" ></el-table-column>
        <el-table-column label="操作" >
          <template slot-scope="scope">
            <el-button type="danger" size="mini" @click="deleteById(scope.row.id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination background layout="prev, pager, next"
                     :page-size="pager.pageSize"
                     :total="pager.total"
                     :page-count="pager.pages"
                  :current-page.sync="pager.pageNo"
      @current-change="getlist">
        </el-pagination>
    </el-col>

  </el-row>


</template>

<style scoped>

</style>
